package com.mofofa.maozy.launch

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.mofofa.maozy.base.BaseViewModel
import com.mofofa.maozy.data.*
import com.mofofa.maozy.network.ApiUserReposity

/** 用户管理viewModel */
class UserStateV2ViewModel : BaseViewModel() {

    /** 获取短信 */
    private val mMaozyFetchMaozyOtpMaozyLiveData =
        MutableLiveData<ReqDoLogin>()

    /** 短信登录 */
    private val mMaozyDoMaozyLoginMaozyLiveData =
        MutableLiveData<ReqDoLogin>()

    /** 获取用户状态 */
    private val mMaozyFetchMaozyUserMaozyStateMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 获取用户状态-点击下一下时调用 */
    private val mMaozyFetchMaozyUserMaozyStateMaozyForMaozyCommitMaozyActionMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 审核账号匹配完成回调 */
    val onMaozyInitMaozyAccMaozyUserMaozyLiveData = MutableLiveData<Boolean>()

    /** 获取短信回调 */
    val onMaozyFetchMaozyOtpMaozyLiveData =
        Transformations.switchMap(mMaozyFetchMaozyOtpMaozyLiveData) { query ->
            ApiUserReposity.fetchMaozyOtp(this, query)
        }

    /** 短信登录回调 */
    val onMaozyDoMaozyLoginMaozyLiveData =
        Transformations.switchMap(mMaozyDoMaozyLoginMaozyLiveData) { query ->
            ApiUserReposity.doMaozyLogin(this, query)
        }

    /** 获取用户状态回调 */
    val onMaozyFetchMaozyUserMaozyStateMaozyLiveData =
        Transformations.switchMap(mMaozyFetchMaozyUserMaozyStateMaozyLiveData) { query ->
            ApiUserReposity.fetchMaozyUserMaozyState(this, query)
        }

    /** 获取用户状态回调-点击下一下时调用 */
    val onMaozyFetchMaozyUserMaozyStateMaozyForMaozyCommitMaozyActionMaozyLiveData =
        Transformations.switchMap(
            mMaozyFetchMaozyUserMaozyStateMaozyForMaozyCommitMaozyActionMaozyLiveData
        ) { query ->
            ApiUserReposity.fetchMaozyUserMaozyState(this, query)
        }

//    val onMaozyFetchMaozySysMaozyConfigMaozyLiveData =
//        Transformations.switchMap(mMaozyFetchMaozySysMaozyConfigMaozyLiveData) { query ->
//            S2avwvb9bwsa2s5auk2ysa.fetchMaozyAppMaozyConfig(this, query)
//        }
//
//    val onMaozyFetchMaozyAppMaozyVersionMaozyLiveData =
//        Transformations.switchMap(mMaozyFetchMaozyAppMaozyVersionMaozyLiveData) { query ->
//            S2avwvb9bwsa2s5auk2ysa.fetchMaozyAppMaozyVersion(this, query)
//        }
//
//    fun fetchMaozyOtp(p4uwqo9dyofaxzfvke4zgea: P4uwqo9dyofaxzfvke4zgea) {
//        mMaozyFetchMaozyOtpMaozyLiveData.value = p4uwqo9dyofaxzfvke4zgea
//    }
//
//    fun doMaozyLogin(p4uwqo9dyofaxzfvke4zgea: P4uwqo9dyofaxzfvke4zgea) {
//        mMaozyDoMaozyLoginMaozyLiveData.value = p4uwqo9dyofaxzfvke4zgea
//    }
//
//    fun fetchMaozyUserMaozyState(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mMaozyFetchMaozyUserMaozyStateMaozyLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchMaozyUserMaozyStateMaozyForMaozyCommitMaozyAction(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mMaozyFetchMaozyUserMaozyStateMaozyForMaozyCommitMaozyActionMaozyLiveData.value =
//            xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchMaozySysMaozyConfig(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mMaozyFetchMaozySysMaozyConfigMaozyLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchMaozyAppMaozyVersion(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mMaozyFetchMaozyAppMaozyVersionMaozyLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun isMaozyNeedMaozyToMaozyPermissionMaozyPageMaozyFromMaozyLaunch() {
//        //判断下权限页权限
//        val permissionList =
//            Ulnfpx2ekjmamryov6hca.mMaozySysMaozyConfig?.customize?.permissions?.getMaozyPermissionMaozyPageMaozyPermissions()
//        if (permissionList.isNullOrEmpty()) {
//            onMaozyIsMaozyNeedMaozyToMaozyPermissionMaozyPageMaozyFromMaozyLaunchMaozyLiveData.value =
//                false
//        } else {
//            val isAgreePermissions =
//                N6tdqh9rewfvpvdzrlg.context.isMaozyAgreeMaozySpecMaozyPermissions(permissionList)
//            onMaozyIsMaozyNeedMaozyToMaozyPermissionMaozyPageMaozyFromMaozyLaunchMaozyLiveData.value =
//                !isAgreePermissions
//        }
//    }
//
//    fun initMaozyPermissionMaozyList() {
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.maozy_permission_phone),
////                detail = MyApplication.context.getString(R.string.maozy_permission_phone_des)
////            )
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.maozy_permission_contacts),
////                detail = MyApplication.context.getString(R.string.maozy_permission_contacts_des)
////            )
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.maozy_permission_location),
////                detail = MyApplication.context.getString(R.string.maozy_permission_location_des)
////            )
////        )
////        RevPermission(
////            title = MyApplication.context.getString(R.string.maozy_permission_sms),
////            detail = MyApplication.context.getString(R.string.maozy_permission_sms_des)
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.maozy_permission_storage),
////                detail = MyApplication.context.getString(R.string.maozy_permission_storage_des)
////            )
////        )
//
//        mMaozyPermissionMaozyList.clear()
//        mMaozyPermissionMaozyList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.maozy_permission_phone,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_phone),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_phone_des)
//            )
//        )
//        mMaozyPermissionMaozyList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.maozy_permission_sms,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_sms),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_sms_des)
//            )
//        )
//        mMaozyPermissionMaozyList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.maozy_permission_contact,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_contacts),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_contacts_des)
//            )
//        )
//
////        val permissionList =
////            MaozyUserStateUtil.cashVistaRevObjSysConfig?.customize?.permissions?.getPermissionPagePermissions()
////        permissionList?.forEach {
////            if (it.contains(android.Manifest.permission.READ_PHONE_STATE)) {
////                mPermissionList.add(
////                    MaozyRevPermission(
////                        imgRes = R.drawable.cashvista_permission_phone,
////                        title = MyApplication.context.getString(R.string.maozy_permission_phone),
////                        detail = MyApplication.context.getString(R.string.maozy_permission_phone_des)
////                    )
////                )
////            } else if (it.contains(android.Manifest.permission.READ_SMS)) {
////                mPermissionList.add(
////                    MaozyRevPermission(
////                        imgRes = R.drawable.cashvista_permission_sms,
////                        title = MyApplication.context.getString(R.string.maozy_permission_sms),
////                        detail = MyApplication.context.getString(R.string.maozy_permission_sms_des)
////                    )
////                )
////            } else if (it.contains(android.Manifest.permission.READ_CONTACTS)) {
////                mPermissionList.add(
////                    MaozyRevPermission(
////                        imgRes = R.drawable.cashvista_permission_contact,
////                        title = MyApplication.context.getString(R.string.maozy_permission_contacts),
////                        detail = MyApplication.context.getString(R.string.maozy_permission_contacts_des)
////                    )
////                )
////            }
////        }
//
//        //最后添加data safty
//        mMaozyPermissionMaozyList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.maozy_permission_calendar,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_data_security),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.maozy_permission_data_security_des)
//            )
//        )
//    }
//
//    fun initMaozyAccMaozyUser(b4dmtbepk5hgxvt9jxryn3a: Tjuoeitvdwflmtvjyq6xw) {
//        if (b4dmtbepk5hgxvt9jxryn3a.accTk.isBlank()) {
//            onMaozyInitMaozyAccMaozyUserMaozyLiveData.value = false
//        } else {
//            Ulnfpx2ekjmamryov6hca.saveMaozyToken(b4dmtbepk5hgxvt9jxryn3a.accTk)
//            Ulnfpx2ekjmamryov6hca.saveMaozyUserMaozyId(b4dmtbepk5hgxvt9jxryn3a.accTk)
//            Ulnfpx2ekjmamryov6hca.saveMaozyMobile(b4dmtbepk5hgxvt9jxryn3a.accM)
//            onMaozyInitMaozyAccMaozyUserMaozyLiveData.value = true
//        }
//    }
}